Skip to content

Quarantine: every test has a state and a next step - #669

Merged
nambok merged 2 commits into
mainfrom
quarantine-actions
Nov 14, 2026
Merged

nambok merged 2 commits into
mainfrom
quarantine-actions

Conversation

@nambok

@nambok nambok commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A quarantined end-to-end test was a dead end: a team's quarantined tests sat there for days, some for weeks, each with one button (release) and nothing happening. This makes quarantine a place a test passes through. Every quarantined test has a state and a next step, CoderHelm works the oldest first, a test that proved healthy leaves by itself, and a test can be removed by a pull request the team approves.

Why a quarantined test with no fix pull request sat there, from the code as it was:

Reason What happened Now
Never eligible An automatic fix needed 20 runs in 30 days, a 5% failure rate and CI time lost in the last 7 days. A quarantined test costs no pull request anything, so it rarely qualified. A quarantined test qualifies with any failure in 30 days. The old bar still applies to flaky tests that are not quarantined.
Order The week's fixes went to whichever qualifying test a default-branch run listed first, and only tests in that run were considered. The repository's tests are ordered: longest quarantined first, then how often it fails, then CI time lost. Looked at on every default-branch run and in the hourly sweep.
A fix failed once Any fix status, including failed, excluded the test from automatic fixes for good. Tried again by itself 7 days later, two attempts in all. The row says why the last one ended and offers the actions.
A person asked The gateway marked the test reproducing and queued the request; the worker read that mark as a fix already under way and dropped the request. The mark then blocked every later request and every automatic fix. The mark carries no start time, the worker starts the fix, and a mark nobody started is cleared by the sweep.
Health went back to healthy "Fix this test" was refused unless the test's health was flaky, and a quarantined test's health returns to healthy after 7 quiet days. A quarantined test can be fixed whatever its health says.
Weekly cap reached Two automatic fixes per repository per week, logged and shown nowhere. Still two by default, now a team setting (1 to 10) shown on the page with why it exists and the day it starts again. A person's request is never counted.
Fix run ended with nothing, or its pull request was closed The status stayed fixing or opened forever. The sweep reads the pull request: merged, closed (by whom, when) or no pull request a day after the run started, each recorded as the reason.
Fix merged Nothing took the test out of quarantine. The only rule after a merge was "fixed" health after 30 days, which never touched the quarantine flag. The test proves the fix (below) and leaves by itself. A failure after the merge is a fix that did not hold.
Healthy again Stayed quarantined until someone released it by hand. Leaves by itself (below).
Cause classed as environment Never a blocker in code, but the label was one sentence, kept forever, and handed to the fix as is. The diagnosis names what the test depends on and how to make it independent, the fix is told to do that, and a diagnosis the runs disprove is marked out of date.
No owner Never a blocker: a ticket went to the repository's issues when tickets were on. Tickets were only filed during a run that included the test. Tickets are also filed by the sweep, and closed when the test leaves quarantine.
Not running A workflow that skips quarantined tests gives no runs, so no fix and no proof. Still true, and now said on the row, with fix and remove offered.

Changes

Leaving quarantine by itself (common/src/e2e/quarantine.rs, applied in detect::apply_run as each run is recorded and in the sweep)

Threshold Value Basis
Passes in a row, no failure and no pass on a retry 20 detect::RATE_MIN_RUNS, the runs the flaky rule needs before it judges a rate, and the repeat runs a fix must hold for (BURN_IN_RUNS; a test asserts they are equal)
On more than one pull request or branch 2 detect::BROKEN_MIN_SHAS, the broken rule's "more than one commit"
From the first of those passes to the last 2 hours New. Longer than one push's CI cycle, short enough that a test healthy all afternoon leaves the same day
Counted from runs after the last failure, the quarantine itself, and a merged fix
Unstable quarantined again 2 times within 30 days of leaving by itself; then also 7 days without a failure FLIPS_FOR_FLAKY, RATE_WINDOW_DAYS, RESOLVE_DAYS
  • The release is recorded with its evidence (passes, pull requests and branches, hours, last failure), as an event in the test's history and on its summary, and the ticket filed for it is commented on and closed.
  • A released flaky test becomes healthy and is judged from the release on (detect::decide), so the flips that put it there do not quarantine it again on its next run. A new flake quarantines it again by the existing rule, and that is counted as a bounce.
  • Manual release is unchanged.

A cause the history disproves

  • Marked out of date after 10 clean passes in a row for a cause outside the test (environment, network; detect::BROKEN_WINDOW, since such a cause fails every run while it lasts) or 20 for any other, on more than one pull request or branch.
  • The note says what changed as far as the repository shows: commits to the test's file since its last failure, or that the file did not change so the change is outside the test. Nothing is said when the file can't be found.
  • Worked out again when the test next fails. The fix is never handed an out-of-date diagnosis as fact.
  • The classification now also returns what the test depends on and how it can be made independent; "the environment" alone is not accepted as an answer.

Every row has a state and a next step

  • Test summaries carry quarantine (state, headline, link to the pull request or the run, the earlier attempt that did not hold, why CoderHelm has not fixed it by itself, the actions that can be taken, progress toward leaving), plus unstable, release, removal, removed and auto_fix.
  • GET /api/tests and GET /api/tests/:id add auto_fixes (the week's count per repository) and fill in what only the whole list knows: the cap, or the test's place in line. Quarantined rows are read from their records when the quarantine list is asked for, since what a row says can change with the date.
  • POST /api/tests/:id/fix works for any quarantined or flaky test with no fix in flight, and again after a fix that did not hold.
  • The fix run's id is named when it is queued, so the row links to the run before a pull request exists.

Removing a test

  • POST /api/tests/:id/remove (same permission as fix) starts a run on ticket E2E-RM-<test id> that deletes the one test case (the file only when it is the file's only test) and what only it used: page objects, fixtures, helpers, test data, test map entries, specs and docs that list it. It keeps the suite green and changes no application code.
  • The description gets a section CoderHelm writes from the record, through description::save: how long it was quarantined, its 30-day history, fix attempts and why they ended, the recorded cause, and which healthy tests still cover the same file or tag, or that none does and what is lost.
  • CoderHelm never merges it. The merge gate is told no_merge for that pull request before its description is written, whatever the team's on-approve setting.
  • CoderHelm proposes a removal by itself only when all of this holds: quarantined 30 days (FIXED_DAYS), two fixes that did not hold, another healthy test covers the same file or tag, no fix in flight, not passing its way out, and no removal proposed before. One per repository per sweep, counted against the weekly number. A declined proposal is never made again.
  • When the pull request merges the test leaves every list and its record names who approved and who merged. When it is closed the row says by whom and offers the actions again.
  • The removal run is not held to the fix rules (test_fix::for_run), which refuse a deleted test.

The sweep (worker/src/passes/quarantine_work.rs, called from the existing ReviewReminder tick, at most once an hour per team)

  • Teams are found through an index kept in the tests table (settings_index), written when settings are saved and rebuilt from one filtered scan a day, so teams that saved settings before this are found without a manual step.
  • For each quarantined test or work in flight: release check, cause check, fix and removal pull requests read from GitHub (state, checks), stalled runs, tickets due. Then the repository's automatic fixes and at most one removal proposal.
  • Idempotent: quarantine::settle changes nothing the second time, and a record is written only when it or what its row says changed.

Shared files touched

  • services/worker/src/main.rs: the sweep call in the ReviewReminder arm.
  • services/worker/src/passes/mod.rs: pub mod quarantine_work, E2E-RM- in is_internal_ticket.
  • services/worker/src/clients/github.rs: close_issue.
  • services/worker/src/passes/test_fix.rs: removal tickets skip the fix evidence.
  • services/gateway/src/main.rs, permissions.rs: the remove route under the tests capability.
  • services/gateway/src/routes/run_trigger.rs: a removal run links to its test.
  • services/worker/src/passes/incidents/mod.rs, docs/incidents.md: case aw.

No change to docs/api/openapi.json: the /api/tests routes are not in the public document, and the two public CI routes keep their shape.

Cost

  • The weekly default is unchanged at 2 per repository, and removal proposals share it, so automatic spend does not rise unless a team raises the number.
  • A cause is worked out again only on a failure after it was marked out of date, within the existing limit of 5 classifications per run.
  • The sweep makes GitHub calls only for tests with a pull request or a stalled run, at most 200 tests per team per hour.

Verification

  • cargo fmt --check --all, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace: all pass locally.
  • common::e2e::quarantine tests: progress and release (the 35-pass case, one branch only, a burst inside two hours, passes before the quarantine or a merged fix), the bounce case and the quiet week, cause staleness at 10 and 20, a merged fix that fails again, every hold reason with its line, each row state with its link and actions, ordering, the cap line and week boundaries, request guards, removal evidence, the proposal rule, the ticket and the description section, and the merged-removal record.
  • detect test: a released test is not quarantined again by its old flips, and is by new ones.
  • Worker tests: the gateway's mark is not read as a fix under way, a quarantined test qualifies without costing CI time, the environment diagnosis reaches the fix, pull request and check states, approvers, the removal branch, source checks that automatic paths claim before they queue and that nothing in the pass merges or writes a description outside description::save.
  • Incident case aw_quarantine_dead_end: the team's scenario replayed through apply_run, standing, auto_fix_order, overlay and the removal rule, including that no combination of fix and removal state leaves a row without a link or an action.
  • Not verified live: nothing here was run against GitHub, DynamoDB or the queue. The sweep's team index, the pull request reads, closing a ticket, the description write on a removal pull request, the merge gate honouring no_merge for it, and a full removal run by the agent are covered by unit tests of their decisions only.

A quarantined test was left with one button and nothing happening.
Now it leaves by itself once its runs prove it healthy (20 clean
passes in a row on more than one pull request or branch, over two
hours), a cause its runs disprove is marked out of date, automatic
fixes go to the longest quarantined first and try again after a fix
that did not hold, a person's fix request is no longer dropped as a
duplicate of its own mark, and a test can be removed by a pull request
the team approves and CoderHelm never merges. The weekly number of
automatic fixes is a team setting, unchanged at 2.
# Conflicts:
#	docs/incidents.md
#	services/worker/src/passes/incidents/mod.rs
@nambok
nambok merged commit ca6134a into main Nov 14, 2026
10 checks passed
@nambok
nambok deleted the quarantine-actions branch November 14, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant